package com.androway.model;

import com.androway.services.Requester;
import com.androway.services.Requester.RequestType;

abstract public class AbstractModel
{
	public static interface OnChangedListener
	{
		public void onSuccess(RequestType type, String service);

		public void onError(RequestType type, String errorMessage);
	}

	protected Requester requester = new Requester();
	protected OnChangedListener listener;

	protected void get(String url, Class<?> clazz, String service)
	{
		requester.doRequest(url, RequestType.GET, clazz, service);
	}

	protected void put(String url, Object obj, String service)
	{
		requester.doRequest(url, RequestType.PUT, obj, service);
	}

	protected void post(String url, Object obj, String service)
	{
		requester.doRequest(url, RequestType.POST, obj, service);
	}

	protected void delete(String url, String service)
	{
		requester.doRequest(url, RequestType.DELETE, null, service);
	}

	public void setListener(OnChangedListener listener)
	{
		this.listener = listener;
	}
}
